package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import modules.GameDispatcher;
	import modules.communication.Communication;
	import modules.lobby.Lobby;
	import modules.login.Login;
	import modules.login.LoginEvent;

	[SWF(width="800",height="600")]
	public class LiveChat extends Sprite
	{
		private var dispather:GameDispatcher = GameDispatcher.instance;
		
		public function LiveChat()
		{
			this.stage.addEventListener(MouseEvent.RIGHT_CLICK, function(event:MouseEvent):void
			{
				stage.nativeWindow.close();
			});
			
			this.stage.addEventListener(MouseEvent.MOUSE_DOWN,function(event:MouseEvent):void
			{
				stage.nativeWindow.startMove();
			});
			
			init();
		}
		
		private function init():void
		{
			MyCC.initFlashConsole(this);
			
			initUI();
			initMoudles();
			
			dispather.dispatchEvent(new LoginEvent(LoginEvent.LOGIN_SHOW));
		}
		
		/**
		 * 初始化模块
		 **/
		private function initMoudles():void
		{
			Communication.init();
			
			Login.init();
			Lobby.init();
		}
		
		private function initUI():void
		{
			UIAllRefer.stage = this.stage;
			
			this.stage.addChild(UIAllRefer.backLayer);
			this.stage.addChild(UIAllRefer.contentLayer);
			this.stage.addChild(UIAllRefer.popLayer);
			this.stage.addChild(UIAllRefer.infoLayer);
			this.stage.addChild(UIAllRefer.tipLayer);
		}
		
	}
}
